package com.zuowei.ycy.ui;


import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.and.yzy.frame.base.BaseFrameAty;
import com.zuowei.ycy.R;
import com.zuowei.ycy.user.domain.ResultInfo;
import com.zuowei.ycy.user.util.AppJsonUtil;

import butterknife.Bind;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Response;

public abstract class BaseToolbarAty extends BaseFrameAty {

    public boolean isShowToast = true;
    @Bind(R.id.toolbar)
    public Toolbar mToolbar;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setSupportActionBar(mToolbar);

        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                finish();
            }
        });

    }

    @Override
    public boolean setIsInitRequestData() {
        return false;
    }

    @Override
    public void btnClick(View view) {

    }

    @Override
    public void onFailure(String result, Call<ResponseBody> call, Response<ResponseBody> response, int what) {
        if (isShowToast) {
            ResultInfo resultInfo = AppJsonUtil.getResultInfo(result);
            showToast(resultInfo.getMessage());
        }


        super.onFailure(result, call, response, what);
    }
}
